package com.abe.libcore.view.common

import android.app.Dialog
import android.content.Context
import android.content.DialogInterface

abstract class BaseDialog : Dialog {
    constructor(context: Context) : super(context) {}

    constructor(context: Context, themeResId: Int) : super(context, themeResId) {}

    constructor(context: Context, cancelable: Boolean, cancelListener: DialogInterface.OnCancelListener) : super(context, cancelable, cancelListener) {}

    override fun show() {
        super.show()
        val dialogWindow = window ?: return
        val lp = dialogWindow.attributes
        val d = context.resources.displayMetrics // 获取屏幕宽、高用
        lp.width = (d.widthPixels * 0.95).toInt() // 宽度设置为屏幕的0.8
        dialogWindow.attributes = lp
    }
}